package com.ag.lwc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbEventSource;
import com.ag.common.AgException;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;
import com.ag.lwc.dao.MyTbEventSourceDAO;
@Service("EventSourceService")
public class EventSourceServiceImpl implements com.ag.lwc.service.EventSourceService {
	@Resource(name="lwcTbEventSourceDAO")	
	private	MyTbEventSourceDAO eventSourceDAO;
	@Resource(name="iDServiceImpl")
	private IIDService 	idService;	
	private IDUtil idUtil;
	public void setIdService(IIDService idService) {
	this.idService = idService;
}
	public void setEventSourceDAO(MyTbEventSourceDAO eventSourceDAO) {
		this.eventSourceDAO = eventSourceDAO;
	}

	@Override
	public void delete(TbEventSource eventSource) {
		eventSourceDAO.delete(eventSource);

	}

	@Override
	public List<TbEventSource> findAll() {
		// TODO Auto-generated method stub
		return eventSourceDAO.findAll();
	}

	@Override
	public TbEventSource findById(String id) {
		// TODO Auto-generated method stub
		return eventSourceDAO.findById(id);
	}

	@Override
	public void update(TbEventSource eventSource) {
	//	eventSourceDAO.attachDirty(eventSource);
		TbEventSource myTbEventSource = eventSourceDAO.findById(eventSource.getEsId());
		myTbEventSource.setEsEventSource(eventSource.getEsEventSource());
		eventSourceDAO.attachDirty(myTbEventSource);

	}

	@Override
	public void save(TbEventSource eventSource) throws AgException{
		long index=	idUtil.TB_EVENT_SOURCE;
		String id=	idService.findTablePK(index);
		eventSource.setA(IDUtil.PRESERVE);
		eventSource.setEsId(id);
		eventSourceDAO.save(eventSource);

	}

	@Override
	public void delete(String id) {
		eventSourceDAO.delete(id);
		
	}

}
